/* lex */

#ifndef BFLEX_H
#define BFLEX_H

#include "bio.h"

#define MAXNAMELEN 30

typedef unsigned char Token_t;

typedef struct {
	Token_t t;
	int extra;
} Tokendata;

typedef struct lexstate{
	IGT* i;
	int current;
	int linenum;
	int errors;
}LState;

#define FIRST_POS 1

// Define the tokens
enum Tokens{
	MOV = FIRST_POS,
	ADD, SET, INPUT, OUTPUT, LOOP,
	END, INT, CHAR, NUM, EOS, ERR
};

void initLState(LState* l, IGT* i);
Tokendata lex(LState* l);

#define next(l) ((l)->current = igetc((l)->i))
#define curr(l)	((l)->current)

/* useful marcos */
#define notsep(c) ((c) != ' ' && (c) != '\t' && (c) != '\n' && (c) != EOI)
#define tok2dat(t, e) ((Tokendata){t, e})

#endif	/* BFPARSER_H */

